package com.xhwl.logistics.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xhwl.common.enums.CodeEnum;
import com.xhwl.common.pojo.ResultJson;
import com.xhwl.common.pojo.cent.sdata.Account;
import com.xhwl.common.pojo.cent.vehicle.VehcParkingLot;
import com.xhwl.common.query.cent.vehicle.ParkingLotQuery;
import com.xhwl.logistics.service.IVehcParkingLotService;
import com.xhwl.common.vo.cent.vehicle.ParkingLotVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Lu.Aaron
 * @since 2021-02-08
 * @menu 车场
 */
//@RestController
@Api(tags = "车场")
@Slf4j
@RequestMapping("/parkingLot")
public class VehcParkingLotController {
    @Autowired
    private IVehcParkingLotService vehcParkingLotService;

    @ApiOperation(value = "新增车场",notes = "输入框有required标识的字段为必填项", response = ResultJson.class, httpMethod = "POST")
    @ResponseBody
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public ResultJson add(@RequestHeader Short industryId,@ApiParam(value = "body字段含义请看model",required = true)@RequestBody ParkingLotVO parkingLotVO, Account account) {

        vehcParkingLotService.add(parkingLotVO,account,industryId);
        return  new ResultJson(true, CodeEnum.SUCCESS.getCode(),"新增成功");
    }

    @ApiOperation(value = "修改车场",notes = "输入框有required标识的字段为必填项", response = ResultJson.class, httpMethod = "POST")
    @ResponseBody
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public ResultJson update(@RequestHeader Short industryId,@ApiParam(value = "body字段含义请看model",required = true)@RequestBody ParkingLotVO parkingLotVO,Account account) {

        vehcParkingLotService.edit(parkingLotVO,account,industryId);
        return  new ResultJson(true, CodeEnum.SUCCESS.getCode(),"修改成功");
    }

    @ApiOperation(value = "删除车场",notes = "输入框有required标识的字段为必填项", response = ResultJson.class, httpMethod = "POST")
    @ResponseBody
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public ResultJson delete(@RequestHeader Short industryId,@ApiParam(value = "车场id",required = true) @RequestParam(value = "id") Integer id) {

        vehcParkingLotService.delete(id,industryId);
        return  new ResultJson(true, CodeEnum.SUCCESS.getCode(),"删除成功");
    }

    @ApiOperation(value = "车场管理分页",notes = "输入框有required标识的字段为必填项", response = ResultJson.class, httpMethod = "POST")
    @ResponseBody
    @RequestMapping(value = "/page", method = RequestMethod.POST)
    public ResultJson parkingLotPage(@RequestBody ParkingLotQuery parkingLotQuery) {
        Page<VehcParkingLot> parkingLotPage =vehcParkingLotService.parkingLotPage(parkingLotQuery);
        return  new ResultJson(true, CodeEnum.SUCCESS.getCode(),"查询成功",parkingLotPage);
    }

    @ApiOperation(value = "车场列表",notes = "输入框有required标识的字段为必填项", response = ResultJson.class, httpMethod = "GET")
    @ResponseBody
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public ResultJson list(ParkingLotQuery parkingLotQuery) {
        List<VehcParkingLot> vehcParkingLotList =vehcParkingLotService.list(parkingLotQuery);

        return  new ResultJson(true, CodeEnum.SUCCESS.getCode(),"查询成功",vehcParkingLotList);
    }


}

